package com.zhu.config.security;

import com.zhu.base.http.SystemCode;
import com.zhu.base.util.RestUtil;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author JoyBoy
 * @create 2021-12-23 20:17
 */
@Component
public class RestLoginAuthenticationEntryPoint extends LoginUrlAuthenticationEntryPoint {

    public RestLoginAuthenticationEntryPoint() {
        super("/gim/api/user/login");
    }

    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response,
                         AuthenticationException authException){
        RestUtil.response(response, SystemCode.UNAUTHORIZED);
    }
}
